package com.xiaohu.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.xiaohu.common.dao.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM `user` WHERE access_key = #{accessKey}")
    public User selectSecretKeyByAccessKey(@Param("accessKey") String accessKey);


    @Update("UPDATE `user` SET `user`.total = `user`.total + 1 WHERE `user`.access_key = #{accessKey}")
    public Integer increaseUserTotalByAccessKey(@Param("accessKey") String accessKey);


    @Update("UPDATE `user` SET total = 0")
    public Integer UserTotalEmpty ();
}
